#include "stdafx.h"
#include <map>
#include "Game/PoolManager/PoolManager.h"
#include "UIAnimHelper.h"

static std::map<UIAnimFlag::GlobleUIAnimFlag, UIAnim *> g_AllGlobalUIAnim;

static pool<UIAnim>			g_AllUIAnim;
static pool<UIChannel>		g_AllUIChannel;
static pool<UITimeline>		g_AllUITimeline;

void InitAllGlobalUIAnim();


void UIAnimHelper::InitHelper()
{
	g_AllUIAnim.InitPool(18);
	g_AllUIChannel.InitPool(34);
	g_AllUITimeline.InitPool(34);

	InitAllGlobalUIAnim();
}

void UIAnimHelper::ClearHelper()
{
	g_AllUIAnim.ClearPool();
	g_AllUIChannel.ClearPool();
	g_AllUITimeline.ClearPool();
}

UIChannel *UIAnimHelper::GetAvalidChannel()
{
	UIChannel *pChannel = g_AllUIChannel.GetFreeObject();
	ASSERT( pChannel );
	return pChannel;
}
UITimeline * UIAnimHelper::GetAvalidTimeline()
{
	UITimeline *pTimeline = g_AllUITimeline.GetFreeObject();
	ASSERT( pTimeline );
	return pTimeline;
}
UIAnim * UIAnimHelper::GetAvalidAnim()
{
	UIAnim *pAnim = g_AllUIAnim.GetFreeObject();
	ASSERT( pAnim );
	return pAnim;
}

UIAnim *UIAnimHelper::CreateUIAnim(bool loop, float time)
{
	UIAnim *pAnim = pAnim = GetAvalidAnim();
	pAnim->Init(loop, time);
	return pAnim;
}
UIChannel *UIAnimHelper::CreateUIChannel(UI_ANIMATION::CHANNEL_TYPE type, int targetIndex)
{
	UIChannel *pChannel = GetAvalidChannel();
	pChannel->Init(type, targetIndex);
	return pChannel;
}

UITimeline *UIAnimHelper::CreateUITimeline(UI_ANIMATION::TIMELINE_STYLE style)
{
	UITimeline *pTimeline = GetAvalidTimeline();
	pTimeline->m_style = style;
	return pTimeline;
}

UIAnim *UIAnimHelper::GetGlobleUIAnim(UIAnimFlag::GlobleUIAnimFlag flag)
{
	return g_AllGlobalUIAnim[flag];
}

void CreateEnterTouchOfSpriteButtonAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(4.f,1.18f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 4.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::SpriteButtonTouchEnter,pAnim ) );
}


void CreateExitTouchOfSpriteButtonAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.18f); UI_ADD_KEY(4.f,1.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 4.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::SpriteButtonTouchExit,pAnim ) );
}

void CreateEnterTouchOfTextButtonAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(4.f,1.18f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 4.0f);
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::TextButtonTouchEnter,pAnim ) );
}

void CreateExitTouchOfTextButtonAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.18f); UI_ADD_KEY(4.f,1.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 4.0f);
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::TextButtonTouchExit,pAnim ) );
}

void CreateFlashTextNormalAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(4.9999f,1.18f); 
	UI_ADD_KEY(5.f,0.0f);  UI_ADD_KEY(7.9999f,0.0f);
	UI_ADD_KEY(8.f,1.18f); UI_ADD_KEY(10.f,1.0f); UI_ADD_KEY(15.f,1.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(true, 15.0f);
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::FlashTextNormal,pAnim ) );
}

void CreateButtonGroupEnterAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,-320.0f); UI_ADD_KEY(10.f,-120.0f); UI_ADD_KEY(20.f,0.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 20.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ButtonGroupEnter,pAnim ) );
}

void CreateButtonGroupExitAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(5.f,360.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 5.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ButtonGroupExit,pAnim ) );
}

void CreateButtonGroupEnter2Anim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,-320.0f); UI_ADD_KEY(2.0f,-320.0f); UI_ADD_KEY(12.f,-120.0f); UI_ADD_KEY(20.f,0.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 20.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ButtonGroupEnter_2,pAnim ) );
}

void CreateButtonGroupExit2Anim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(1.0f,0.0f); UI_ADD_KEY(5.f,360.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 5.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ButtonGroupExit_2,pAnim ) );
}

void CreateButtonGroupEnter3Anim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,-320.0f); UI_ADD_KEY(4.0f,-320.0f); UI_ADD_KEY(14.f,-120.0f); UI_ADD_KEY(20.f,0.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 20.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ButtonGroupEnter_3,pAnim ) );
}

void CreateButtonGroupExit3Anim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(2.0f,0.0f); UI_ADD_KEY(5.f,360.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 5.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ButtonGroupExit_3,pAnim ) );
}

void CreateButtonGroupEnter4Anim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,-320.0f); UI_ADD_KEY(6.0f,-320.0f); UI_ADD_KEY(16.f,-120.0f); UI_ADD_KEY(20.f,0.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 20.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ButtonGroupEnter_4,pAnim ) );
}

void CreateButtonGroupExit4Anim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(3.0f,0.0f); UI_ADD_KEY(5.f,360.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 5.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ButtonGroupExit_4,pAnim ) );
}

void CreateButtonGroupEnter5Anim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,-320.0f); UI_ADD_KEY(8.0f,-320.0f); UI_ADD_KEY(18.f,-120.0f); UI_ADD_KEY(20.f,0.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 20.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ButtonGroupEnter_5,pAnim ) );
}

void CreateButtonGroupExit5Anim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(4.0f,0.0f); UI_ADD_KEY(5.f,360.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 5.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ButtonGroupExit_5,pAnim ) );
}


void CreateEnterToLeftSideAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,480.0f); UI_ADD_KEY(60.0f,0.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 60.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::EnterToLeftSide,pAnim ) );
}

void CreateExitFromLeftSideAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(60.0f,-480.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 60.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ExitFromLeftSide,pAnim ) );
}

void CreateEnterToRightUpCornerAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,-480.0f); UI_ADD_KEY(20.0f,0.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionY );
	UI_ADD_KEY(0.0f,+320.0f); UI_ADD_KEY(20.0f,0.0f);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 20.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,-480.0f); UI_ADD_KEY(20.0f,0.0f);
	UI_ADD_TIMELINE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionY );
	UI_ADD_KEY(0.0f,-320.0f); UI_ADD_KEY(20.0f,0.0f);
	UI_ADD_TIMELINE;

	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::EnterToRightUpCorner,pAnim ) );
}

void CreateEnterToLeftUpCornerAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,480.0f); UI_ADD_KEY(20.0f,0.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionY );
	UI_ADD_KEY(0.0f,320.0f); UI_ADD_KEY(20.0f,0.0f);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 20.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,-480.0f); UI_ADD_KEY(20.0f,0.0f);
	UI_ADD_TIMELINE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionY );
	UI_ADD_KEY(0.0f,-320.0f); UI_ADD_KEY(20.0f,0.0f);
	UI_ADD_TIMELINE;

	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::EnterToLeftUpCorner,pAnim ) );
}

void CreateEnterToRightSideAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,-480.0f); UI_ADD_KEY(20.0f,0.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 20.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::EnterToRightSide,pAnim ) );
}

void CreateEnterToDownSideAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionY );
	UI_ADD_KEY(0.0f,-320.0f); UI_ADD_KEY(20.0f,0.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 20.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::EnterToRightSide,pAnim ) );
}

void CreateFlashTextWhenExitAnim()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(1.999f,1.0f); UI_ADD_KEY(2.0f,0.0f); UI_ADD_KEY(3.999f,0.0f); 
	UI_ADD_KEY(4.0f,1.0f); UI_ADD_KEY(5.999f,1.0f); UI_ADD_KEY(6.0f,0.0f); UI_ADD_KEY(7.0f,0.0f); 
	
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 7.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(1.999f,0.0f); UI_ADD_KEY(2.0f,1.0f); UI_ADD_KEY(3.999f,1.0f); 
	UI_ADD_KEY(4.0f,0.0f); UI_ADD_KEY(5.999f,0.0f); UI_ADD_KEY(6.0f,1.0f); UI_ADD_KEY(7.0f,1.0f); 
	
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 1);
	UI_ADD_TIMELINE;

	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(7.0f,1.0f);
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_ADD_TIMELINE;
	UI_ADD_CHANNEL;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::FlashImageWhenExit,pAnim ) );
}


void CreateTextButtonTouchEnterInMainMenuAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(1.0f,1.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 1.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::TextButtonTouchEnterInMainMenu,pAnim ) );
}

void CreateTextButtonExitInMainMenuAnim()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(1.9999f,1.0f); UI_ADD_KEY(2.0f,0.0f); UI_ADD_KEY(3.9999f,0.0f); 
	UI_ADD_KEY(4.0f,1.0f); UI_ADD_KEY(5.9999f,1.0f); UI_ADD_KEY(6.0f,0.0f); UI_ADD_KEY(7.0f,0.0f); 
	
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 7.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(7.0f,1.0f);
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeText, 0);
	UI_ADD_TIMELINE;
	UI_ADD_CHANNEL;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::TextButtonExitInMainMenu,pAnim ) );
}

void CreateRotateAndScalePaperAnim()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,0.2f); UI_ADD_KEY(3.0f,0.5f); UI_ADD_KEY(6.0f,1.0f);
	
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 6.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineRotationZ );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(3.0f,360.0f);UI_ADD_KEY(6.0f,720.0f);
	UI_ADD_TIMELINE;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::RotateAndScalePaper,pAnim ) );
}

void CreateRotateAndScalePaper_ExitAnim()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,0.2f); UI_ADD_KEY(5.0f,0.5f); UI_ADD_KEY(10.0f,1.0f);
	UI_ADD_KEY(80.0f,1.0f);
	
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 80.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineRotationZ );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(5.0f,360.0f);UI_ADD_KEY(10.0f,720.0f);
	UI_ADD_KEY(11.0f,0.0f); UI_ADD_KEY(68.0f,0.0f);
	UI_ADD_KEY(80.0f,720.0f);
	UI_ADD_TIMELINE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,0.0f); 
	UI_ADD_KEY(68.0f,0.0f);
	UI_ADD_KEY(80.0f,-480.0f);
	UI_ADD_TIMELINE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionY );
	UI_ADD_KEY(68.0f,0.0f);
	UI_ADD_KEY(80.0f,+320.0f);
	UI_ADD_TIMELINE;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::RotateAndScalePaper_Exit,pAnim ) );
}


void CreateRotateAndScalePhotoAnim()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,0.1f); UI_ADD_KEY(10.0f,0.5f); UI_ADD_KEY(20.0f,1.0f);
	
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 20.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineRotationZ );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(10.0f,360.0f);UI_ADD_KEY(20.0f,720.0f);
	UI_ADD_TIMELINE;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::RotateAndScalePhoto,pAnim ) );
}

void CreateRotateAndScaleAndMoveRightPhotoAnim()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,0.1f); UI_ADD_KEY(10.0f,0.5f); UI_ADD_KEY(20.0f,1.0f);
	
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 20.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineRotationZ );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(10.0f,360.0f);UI_ADD_KEY(20.0f,720.0f);
	UI_ADD_TIMELINE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(20.0f,110.0f);
	UI_ADD_TIMELINE;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::RotateAndScaleAndMoveRightPhoto,pAnim ) );
}

void CreateRotateAndScaleAndMoveLeftPhotoAnim()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,0.1f); UI_ADD_KEY(10.0f,0.5f); UI_ADD_KEY(20.0f,1.0f);
	
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 20.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineRotationZ );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(10.0f,360.0f);UI_ADD_KEY(20.0f,720.0f);
	UI_ADD_TIMELINE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(20.0f,-110.0f);
	UI_ADD_TIMELINE;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::RotateAndScaleAndMoveLeftPhoto,pAnim ) );
}


void CreateScalePhotoAnim()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,0.1f); UI_ADD_KEY(5.0f,0.5f); UI_ADD_KEY(10.0f,1.0f);
	
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 10.0f);
	UI_ADD_CHANNEL;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ScalePhoto,pAnim ) );
}

void CreateScaleAndMoveLeftPhotoAnim()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,0.1f); UI_ADD_KEY(5.0f,0.5f); UI_ADD_KEY(10.0f,1.0f);
	
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 10.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(10.0f,-110.0f);
	UI_ADD_TIMELINE;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ScalePhotoAndMoveLeft,pAnim ) );
}

void CreateScaleAndMoveRightPhotoAnim()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,0.1f); UI_ADD_KEY(5.0f,0.5f); UI_ADD_KEY(10.0f,1.0f);
	
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 10.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelinePositionX );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(10.0f,110.0f);
	UI_ADD_TIMELINE;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ScalePhotoAndMoveRight,pAnim ) );
}

void CreateSuitButtonTouchEnterAnim()
{
	UI_DEFINE_VARIABLE;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(1.0f,1.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 1.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 1);
	UI_COPY_TIMELINE;
	UI_ADD_CHANNEL;
	
	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::SuitButtonTouchEnter,pAnim ) );
}
void CreateSuitButtonExitAnim()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(7.0f,1.0f);
	
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, 7.0f);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(1.999f,1.0f); UI_ADD_KEY(2.0f,0.0f); UI_ADD_KEY(3.999f,0.0f); 
	UI_ADD_KEY(4.0f,1.0f); UI_ADD_KEY(5.999f,1.0f); UI_ADD_KEY(6.0f,0.0f); UI_ADD_KEY(7.0f,0.0f); 
	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 1);
	UI_ADD_TIMELINE;
	UI_ADD_CHANNEL;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::SuitButtonExit,pAnim ) );
}

const float ROTATE_ANIMATION_TIEM_LENGTH = 600.f;
void CreateArtWorksDetailRotate270To180()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH,1.5f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, ROTATE_ANIMATION_TIEM_LENGTH);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineRotationZ );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH,90.0f);
	UI_ADD_TIMELINE;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ArtWorksDetailRotate270To180,pAnim ) );
}

void CreateArtWorksDetailRotate270To0()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH,1.5f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, ROTATE_ANIMATION_TIEM_LENGTH);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineRotationZ );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH,-90.0f);
	UI_ADD_TIMELINE;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ArtWorksDetailRotate270To0,pAnim ) );
}


void CreateArtWorksDetailRotate270To90()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH,1.5f);
	UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH*2,1.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, ROTATE_ANIMATION_TIEM_LENGTH*2);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineRotationZ );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH,-90.0f);
	UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH*2,-180.0f);
	UI_ADD_TIMELINE;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ArtWorksDetailRotate270To90,pAnim ) );
}

void CreateArtWorksDetailRotate180To270()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH,0.667f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, ROTATE_ANIMATION_TIEM_LENGTH);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineRotationZ );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH,-90.0f);
	UI_ADD_TIMELINE;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ArtWorksDetailRotate180To270,pAnim ) );
}

void CreateArtWorksDetailRotate180To90()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH,0.667f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, ROTATE_ANIMATION_TIEM_LENGTH);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineRotationZ );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH,90.0f);
	UI_ADD_TIMELINE;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ArtWorksDetailRotate180To90,pAnim ) );
}

void CreateArtWorksDetailRotate180To0()
{
	UI_DEFINE_VARIABLE;
	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineScale );
	UI_ADD_KEY(0.0f,1.0f); UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH,0.667f);
	UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH*2,1.0f);

	UI_CREATE_CHANNEL(UI_ANIMATION::ChannelTypeImage, 0);
	UI_ADD_TIMELINE;

	UI_CREATE_ANIM(false, ROTATE_ANIMATION_TIEM_LENGTH*2);
	UI_ADD_CHANNEL;

	UI_CREATE_TIMELINE( UI_ANIMATION::TimelineRotationZ );
	UI_ADD_KEY(0.0f,0.0f); UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH,-90.0f);
	UI_ADD_KEY(ROTATE_ANIMATION_TIEM_LENGTH*2,-180.0f);
	UI_ADD_TIMELINE;

	g_AllGlobalUIAnim.insert( TPairUIAnimFlag(UIAnimFlag::ArtWorksDetailRotate180To0,pAnim ) );
}


void InitAllGlobalUIAnim()
{
	//CreateEnterTouchOfSpriteButtonAnim();
	//CreateExitTouchOfSpriteButtonAnim();

	//CreateEnterTouchOfTextButtonAnim();
	//CreateExitTouchOfTextButtonAnim();

	CreateFlashTextNormalAnim();
	CreateFlashTextWhenExitAnim();

	//CreateButtonGroupEnterAnim();
	//CreateButtonGroupExitAnim();

	//CreateButtonGroupEnter2Anim();
	//CreateButtonGroupExit2Anim();

	//CreateButtonGroupEnter3Anim();
	//CreateButtonGroupExit3Anim();

	//CreateButtonGroupEnter4Anim();
	//CreateButtonGroupExit4Anim();

	//CreateButtonGroupEnter5Anim();
	//CreateButtonGroupExit5Anim();

	//CreateEnterToLeftSideAnim();
	//CreateExitFromLeftSideAnim();

	//CreateEnterToRightSideAnim();

	//CreateEnterToRightUpCornerAnim();

	//CreateEnterToDownSideAnim();

	//CreateEnterToLeftUpCornerAnim();

	//GS_InfoMenu::InitAllUIAnim();

	CreateTextButtonTouchEnterInMainMenuAnim();
	CreateTextButtonExitInMainMenuAnim();

	CreateRotateAndScalePaperAnim();
	CreateRotateAndScalePaper_ExitAnim();

	//CreateRotateAndScalePhotoAnim();
	//CreateRotateAndScaleAndMoveRightPhotoAnim();
	//CreateRotateAndScaleAndMoveLeftPhotoAnim();

	CreateScaleAndMoveRightPhotoAnim();
	CreateScalePhotoAnim();
	CreateScaleAndMoveLeftPhotoAnim();

	CreateSuitButtonTouchEnterAnim();
	CreateSuitButtonExitAnim();

	CreateArtWorksDetailRotate270To180();
	CreateArtWorksDetailRotate270To0();

	CreateArtWorksDetailRotate270To90();

	CreateArtWorksDetailRotate180To270();
	CreateArtWorksDetailRotate180To90();

	CreateArtWorksDetailRotate180To0();
}

